package com.cmy.listener;

import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;


public class TestPanel {
    public static void main(String[] args) {
        Frame frame = new Frame("hello frame");//构建一个窗体
        Panel panel = new Panel(null);//面板
        frame.setLayout(null);//设置窗体布局

        frame.setBounds(500,400,500,500);
        frame.setBackground(Color.blue);
        panel.setBounds(100,100,300,300);
        panel.setBackground(Color.ORANGE);

        frame.add(panel);

        frame.setVisible(true);
        frame.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.out.println("closing");
                System.exit(0);
            }

            @Override
            public void windowActivated(WindowEvent e) {
                System.out.println("active");
            }
        });
        System.out.println("hello");
    }
}

    